package com.project.service.serveOrderService.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.ServeOrderBean;
import com.project.mapper.serveOrderMapper.IServeOrderMapper;
import com.project.service.serveOrderService.IServeOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.List;

@Service
@Transactional
public class ServeOrderServiceImpl implements IServeOrderService {
    @Autowired
    private IServeOrderMapper serveOrderMapper;
    @Override
    public void add(ServeOrderBean serveOrder) {
        serveOrderMapper.add(serveOrder);
    }

    @Override
    public ServeOrderBean findById(int id) {
        return serveOrderMapper.findById(id);
    }

    @Override
    public void update(int id, String state) {
        serveOrderMapper.update(id, state);
    }

    @Override
    public void updateEmployee(int id, int employeeId) {
        serveOrderMapper.updateEmployee(id, employeeId);
    }

    @Override
    public PageInfo<ServeOrderBean> findAll(int pageNO, int storeId) {
        PageHelper.startPage(pageNO,PAGESIZE);
        return PageInfo.of(serveOrderMapper.findAll(storeId));
    }

    @Override
    public PageInfo<ServeOrderBean> findByItem(int pageNO, String state, LocalDate startDate, LocalDate endDate, int userId) {
        PageHelper.startPage(pageNO,PAGESIZE);
        return PageInfo.of(serveOrderMapper.findByItem(state, startDate, endDate, userId));
    }
}
